package org.company.tool.util;

import org.apache.commons.lang3.StringUtils;

public class StringUtil {
    
    /**
     * 按照数据库命名规则转化为java命名规则,eg dpublic_notice ==> dPublicNotice
     * @param name
     * @return
     */
    public static String nameTransfer(char token,String text) {
        int idx = -1;
        while((idx = text.indexOf(token)) >= 0) {
            text = text.replaceFirst(token + "[\\d\\w]", text.substring(idx+1,idx+2).toUpperCase());
        }
        return text;
    }
    
    /**
     * 
     * @method nameTransfer
     * @param text
     * @return
     * @see StringUtils#nameTransfer(char, String)
     */
    public static String nameTransfer(String text) {
        return nameTransfer('_', text);
    }
    
    public static String founderTransfer(String text) {
        return StringUtils.removeStartIgnoreCase(nameTransfer(text), "t");
    }
}
